#ifndef DB_H
#define DB_H

#include "./sqlite_src/sqlite3.h"
#include "MemberAccount.h"
#include "AdminAccount.h"
#include "HotelItem.h"
#include "HotelReview.h"
#include <cstring>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

class HotelItem;
class MemberAccount;

typedef struct HotelSummary{
    string hotelID;
    string name;
    float locationRating;
    float valueForMoneyRating;
    float comfortRating;
    float serviceRating;
    float averageRating;
}HotelSummary;

// helper functions
// convert revGrantedFor
string vecStrToStr(vector<string>&);
vector<string> strToVecStr(string&);

// write SQL statement from object
string maStmt(char, vector<MemberAccount*>&);
string hiStmt(char, vector<HotelItem>&);
string hrStmt(char, vector<HotelReview>&);

// ==========USE THESE FUNCTIONS=================
// pass in the vector you want to insert, select, update, or delete
// first arg: operation you want to perform ('i'nsert, 's'elect, 'u'pdate, or 'd'elete)
// second arg: vector to perform the operation on (vector should be empty for select)
int dbMemberAccount(char, vector<MemberAccount*>&);
int dbHotelItem(char, vector<HotelItem>&);
int dbHotelReview(char, vector<HotelReview>&);

// get average rating over all reviews for a particular hotel
// remember to setprecision when outputting!
// first arg: hotelID
// second arg: float for the average rating
int dbGetAvgHotelRating(string, float&);

// get hotel summary struct (see above) for all hotels reviewed
// remember to setprecision when outputting!
// first arg: vector of HotelSummary structs
int dbGetHotelSummary(vector<HotelSummary>&);

// update memberID
// first arg: old memberID
// second arg: pointer to new memberaccount to update
int dbUpdateMemberID(string&, MemberAccount*&);

#endif